<template>
	<view class="alterPsws">
		<custom-navi :show-home="false">修改密码</custom-navi>
		<view class="alterPsw">
			<view class="alterPsw-list">
				<text>原密码</text>
				<input type="text" value="" password placeholder="请输入原密码" placeholder-style="font-size:28rpx; font-weight:400;" @input="former"/>
			</view>
			<view class="alterPsw-list">
				<text>新密码</text>
				<input type="text" value="" password placeholder="请输入新密码" placeholder-style="font-size:28rpx; font-weight:400;" @input="newPsw"/>
			</view>
		</view>
		<view class="alterPsw-btn" @click="alterBtn">
			完成
		</view>
	</view>
</template>

<script>
	import {changePasswordByOriginalPassword,getStoreInformation} from "../../../../api.js"
	export default{
		data(){
			return{
				originalPassword:'',
				password:'',
			}
		},
		onLoad() {
			
		},
		methods:{
			former(e){
				// console.log(e.detail.value)
				this.originalPassword = e.detail.value
			},
			newPsw(e){
				// console.log(e.detail.value)
				this.password = e.detail.value
			},
			async alterBtn(){
				let params = {
				  originalPassword:this.originalPassword,
				  password:this.password
				}
				try {
				  const {
				    data
				  } = await changePasswordByOriginalPassword(params)
				 console.log(data)
				 uni.setStorageSync('USER_INFO', data)
				 this.$utils.common.toast.fail("修改成功");
				 setTimeout(() => {
				   return this.$utils.common.navigateBack()
				 }, 1000)
				} catch (err) {
				  console.log(err)
				  
				    if (err.data.code != 200) {
				      return this.$utils.common.toast.fail(err.data.message);
				    }
				    
				  
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.alterPsws{
		height: 100vh;
		background-color: rgba(243, 244, 248, 1);
		.alterPsw{
			background-color: rgba(255, 255, 255, 1);
			padding: 0 20rpx;
			&-list{
				padding: 20rpx 32rpx;
				display: flex;
				background-color: rgba(255, 255, 255, 1);
				border-bottom: 1rpx solid rgba(217, 217, 217, 1);
				text{
					font-size:28rpx;
					font-family:PingFang SC;
					font-weight:400;
					color:rgba(80,80,80,1);
					opacity:1;
					margin-right: 20rpx;
				}
			}
			&-list:last-child{
				border-bottom:none
			}
			&-btn{
				width:686rpx;
				height:88rpx;
				background:rgba(12,212,211,1);
				opacity:0.64;
				font-size:34rpx;
				font-family:PingFang SC;
				font-weight:500;
				line-height:88rpx;
				color:rgba(255,255,255,1);
				opacity:1;
				margin: 0 auto;
				margin-top: 82rpx;
				text-align: center;
				border-radius: 10rpx;
				
			}
		}
		
	}
</style>
